package com.javazyw.utils.net;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * <p>.</p>
 *
 * @version 
 * @author dongdh
 * @date 2015年7月8日
 *
 */
public final class SMSUtil {

	private static Log logger = LogFactory.getLog(SMSUtil.class);
	private static String url = "http://smsapi.c123.cn/OpenPlatform/OpenApi?action=sendOnce";
	private static String ac = "1001@501153590001";
	private static String cgid = "52";
	private static String authkey = "E5EA9C4411BB908C4C06629DB75A77B5";
	
	public static String send(String mobile, String message) {
		
		if (StringUtils.isEmpty(mobile) || StringUtils.isEmpty(message)) {
			logger.debug("短信号码或者短信内容为空...");
			return null;
		}
		Map<String, String> params = new HashMap<String, String>();
		params.put("m", mobile);
		params.put("c", message);
		params.put("ac", ac);
		params.put("cgid", cgid);
		params.put("authkey", authkey);
		
		String ret = HttpClientUtil.sendPostRequest(url, params);
		logger.debug("发送短信：mobile=" + mobile);
		logger.debug("发送短信：message=" + message);
		logger.debug("返回：" + ret);
		
		return ret;
	}
	
	public static void main(String[] args) {
		String s = send("18618193268", "测试test1234");
		System.out.println(s);
	}
	
}
